﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components.mainmenu {
    import reprise.ui.*;
    import flash.events.*;
    import reprise.controls.*;
    import flash.utils.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.utils.*;

    public class InventoryDisplay extends UIComponent {

        private var _background:UIComponent;
        private var _slotsDisplay:UIComponent;
        private var _slots:Dictionary;
        private var _currentAnimationFrameNumber:int;

        public static const GEM_CSS_ID:String = "gem";
        public static const GEM_CLICK:String = "GEM_CLICK";

        public static var FIRST_TIME_DATA_SET:Boolean = true;

        public function InventoryDisplay(){
            this._slots = new Dictionary();
            super();
        }
        public function setNumberByType(_arg1:String, _arg2:int):void{
            var _local3:LabelButton = this._slots[_arg1];
            var _local4:int = int(_local3.getLabel());
            _local3.setLabel(String(_arg2));
            if ((((_arg2 > _local4)) && ((_local3.cssID == GEM_CSS_ID)))){
                this._currentAnimationFrameNumber = 1;
                if (!FIRST_TIME_DATA_SET){
                    _local3.addCSSClass("play");
                    _local3.addEventListener(Event.ENTER_FRAME, this.slot_enterFrame);
                };
            };
        }
        private function slot_enterFrame(_arg1:Event):void{
            var _local2:LabelButton = LabelButton(_arg1.target);
            this._currentAnimationFrameNumber++;
            if (this._currentAnimationFrameNumber == 40){
                _local2.removeEventListener(Event.ENTER_FRAME, this.slot_enterFrame);
                _local2.removeCSSClass("play");
            };
        }
        public function showItemByType(_arg1:String):void{
            var _local2:LabelButton = this._slots[_arg1];
            _local2.show();
        }
        public function highlightSlot(_arg1:String):void{
            var _local2:LabelButton = this._slots[_arg1];
            _local2.show();
            _local2.addCSSClass("highlight");
        }
        public function setTooltipByType(_arg1:String, _arg2:String):void{
            var _local3:LabelButton = this._slots[_arg1];
            _local3.setTooltipData(_arg2);
        }
        public function setGemEnabled(_arg1:String, _arg2:Boolean):void{
            var _local3:LabelButton = this._slots[_arg1];
            if (!_local3){
                return;
            };
            mouseEnabled = (_local3.mouseChildren = _arg2);
        }
        public function setEnabled(_arg1:Boolean):void{
            if (_arg1){
                this._background.removeCSSClass("disabled");
            } else {
                this._background.addCSSClass("disabled");
            };
            mouseEnabled = _arg1;
            mouseChildren = _arg1;
        }
        override protected function initialize():void{
            cssID = "inventory";
            super.initialize();
        }
        override protected function createChildren():void{
            this._slotsDisplay = addComponent("inventoryDisplay");
            this._background = addComponent("background");
            this.createSlot(GameConstants.BATTERY);
            this.createSlot(GameConstants.LOVE, GEM_CSS_ID);
            this.createSlot(GameConstants.ICE, GEM_CSS_ID);
            this.createSlot(GameConstants.FIRE, GEM_CSS_ID);
            this.createSlot(GameConstants.COFFEE);
            this.createSlot(GameConstants.AIR, GEM_CSS_ID);
            this.createSlot(GameConstants.STAR, GEM_CSS_ID);
            this.createSlot(GameConstants.WATER, GEM_CSS_ID);
        }
        private function createSlot(_arg1:String, _arg2:String=""):void{
            var _local3:LabelButton = RepriseUtils.addLabelButton(this._slotsDisplay, "myriadProFont inventorySlot", "", this.slot_clicked);
            _local3.addCSSClass(_arg1);
            _local3.setData(_arg1);
            _local3.hide();
            _local3.cssID = _arg2;
            this._slots[_arg1] = _local3;
        }
        private function slot_clicked(_arg1:MouseEvent):void{
            var _local2:LabelButton = LabelButton(_arg1.target);
            if (_local2.cssID == GEM_CSS_ID){
                dispatchEvent(new InfoEvent(GEM_CLICK, _local2.data()));
            };
        }
        public function showGems():void{
            LabelButton(this._slots[GameConstants.ICE]).show();
            LabelButton(this._slots[GameConstants.FIRE]).show();
            LabelButton(this._slots[GameConstants.LOVE]).show();
            LabelButton(this._slots[GameConstants.AIR]).show();
            LabelButton(this._slots[GameConstants.STAR]).show();
            LabelButton(this._slots[GameConstants.WATER]).show();
        }

    }
}//package net.wooga.pets.views.components.mainmenu 
